<html>
<head><meta charset="utf-8"><title>extending everybody_loops · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html">extending everybody_loops</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="130785333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785333">(Aug 02 2018 at 15:35)</a>:</h4>
<p>Hey @eddyb I wanted to get your feedback on something here (<span class="user-mention" data-user-id="121053">@varkor</span> may have opinions too?)</p>



<a name="130785396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785396">(Aug 02 2018 at 15:36)</a>:</h4>
<p>the supposed goal is to include impl's that occur underneath <code>fn</code> bodies</p>



<a name="130785407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785407">(Aug 02 2018 at 15:36)</a>:</h4>
<p>but those <code>impl's</code> might be implementing traits that are only defined in those <code>fn</code> bodies, or in <code>mod</code>s that are only in those <code>fn</code> bodies, etc</p>



<a name="130785451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785451">(Aug 02 2018 at 15:37)</a>:</h4>
<p>IMHO it is not correct for rustdoc to be collecting items with a visitor.</p>



<a name="130785453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785453">(Aug 02 2018 at 15:37)</a>:</h4>
<p>A couple different options I see here are: 1. punt: If you impl a trait that was declared under <code>fn</code>, then you lose (as in, <code>rustdoc</code> might break in some way for you),</p>



<a name="130785502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785502">(Aug 02 2018 at 15:38)</a>:</h4>
<p>And even then, it should be possible for rustdoc to make a visitor that does <em>not</em> visit bodies?</p>



<a name="130785520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785520">(Aug 02 2018 at 15:38)</a>:</h4>
<p>AST is a tree after all.</p>



<a name="130785571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785571">(Aug 02 2018 at 15:39)</a>:</h4>
<p>I guess we can categorize @nagisa's note as Option 2: tell <code>rustdoc</code> to stop doing it whatever way they're doing it now, and instead write a different visitor/folder implementation specialized totheir needs?</p>



<a name="130785759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785759">(Aug 02 2018 at 15:42)</a>:</h4>
<p>option 3: make <code>-Z everybody_loop</code> include all sorts of items underneath <code>fn</code> bodies, beyond <code>impl</code> items. I would assume to be robust (in the sense that output from <code>-Z everybody_loop</code> is meant to be accepted by <code>rustc</code> whenever the original code was accepted) that we would have to include pretty much every kind of item.  (And instead the filtering would be based on inspecting what kind of <code>StmtKind</code> we are looking at.)</p>



<a name="130785999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130785999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130785999">(Aug 02 2018 at 15:47)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> assertly earlier (correctly, I think) that <code>rustdoc</code> is the only serious client of <code>-Z unpretty=everybody_loops</code>. Even I haven't used it in quite some time.</p>



<a name="130786012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786012">(Aug 02 2018 at 15:48)</a>:</h4>
<p>I personally wanted to help with any adjustment that happened to it, in part because I feel responsible for whatever damage it has done, and also because I want to make sure that it keeps working for my own needs in the future.</p>



<a name="130786057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786057">(Aug 02 2018 at 15:48)</a>:</h4>
<p>Having said that, I think I would be totally fine with having it include the items under fn bodies.</p>



<a name="130786092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786092">(Aug 02 2018 at 15:48)</a>:</h4>
<p>(and effectively it would "just" be filtering out all expressions instead of the more invasive rewrite that it did before.)</p>



<a name="130786129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786129">(Aug 02 2018 at 15:49)</a>:</h4>
<p>But either way, I don't think the relatively simple "block accumulation" strategy that <span class="user-mention" data-user-id="119009">@eddyb</span> recommended last night on Discord is <em>quite</em> good enough ...</p>



<a name="130786388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786388">(Aug 02 2018 at 15:54)</a>:</h4>
<p>There might also be things like</p>
<div class="codehilite"><pre><span></span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="s">&quot;foo&quot;</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">Trait</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Struct</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="mi">3</span><span class="p">}];</span><span class="w"></span>
</pre></div>


<p>which is not an item but contains an impl</p>



<a name="130786542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786542">(Aug 02 2018 at 15:57)</a>:</h4>
<p>could the rustdoc driver just stop before item collection and do its stuff there? Without compiling everything we can basically never guarantee that we found everything.</p>



<a name="130786605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786605">(Aug 02 2018 at 15:58)</a>:</h4>
<p>we might even prevent the generation of most MIR (of constants and const fn we'd still need it)</p>



<a name="130786874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786874">(Aug 02 2018 at 16:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> if you don't tab-complete me you won't ping me (e.g. @pnkfelix wouldn't ping you either)</p>



<a name="130786928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786928">(Aug 02 2018 at 16:04)</a>:</h4>
<p>Arg yes I should know that by now</p>



<a name="130786929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786929">(Aug 02 2018 at 16:04)</a>:</h4>
<p>and I assumed that the only sane thing to do is collect all items</p>



<a name="130786931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786931">(Aug 02 2018 at 16:04)</a>:</h4>
<p>including the block nesting around them</p>



<a name="130786934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130786934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130786934">(Aug 02 2018 at 16:04)</a>:</h4>
<p>to not break <code>{ fn foo() {} } { fn foo() {} }</code></p>



<a name="130852504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130852504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130852504">(Aug 03 2018 at 17:42)</a>:</h4>
<p>You’d be surprised how far one might get with insane approaches</p>



<a name="130852505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/extending%20everybody_loops/near/130852505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/extending.20everybody_loops.html#130852505">(Aug 03 2018 at 17:42)</a>:</h4>
<p>This is the problem with a short user name</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>